var Course = {
	items: null,
	itemName: null,
	removeEvt: null,
	data: null,
	createInit: function(){
		$ajax({
			url : "/user/list",
			data: {
				category: UTYPE.PROVIDER
			},
			success: function(res){
				var list = res.result.results;
				var html = '';
				for (var i = 0 ; i < list.length ; i ++){
					html += '<option value="' + list[i]._id + '">' + list[i].username + '('+(list[i].name||"无")+')</option>';
				}
				$("#owner").html(html);
			}
		});
		// $ajax({
		// 	url : "/teacher/list",
		// 	success: function(res){
		// 		var teachers = res.result.results;
		// 		var html = '';
		// 		for (var i = 0 ; i < teachers.length ; i ++){
		// 			html += "<label class='checkbox inline'>" + 
  //                           "    <input id='" + teachers[i]._id + "' value='" + teachers[i]._id + "' type='checkbox' name='teachers' />" + teachers[i].name + 
  //                           "</label>";
		// 		}
		// 		$("#teacherList").html(html);
		// 	}
		// });
		$("#save").click(function(){
			var data = new Object();
			$(".form").find('input').each(function(){
				data[$(this).attr("id")] = $(this).val();
			});
			data.owner = $("#owner").val();	
			if (data.name  == "") 
               return $alert("课程名称不能为空");
          
			if ((data.classHour  >= 1000) || (data.classHour  <= 0)) 
			   return $alert("课时格式错误，请重新输入1~1000！");
			if (data.owner  == "") 
			   return $alert("供应商不能为空");
          	// data.teachers = new Array();
			// $("#form").find("input[type='checkbox']:checked").each(function(i){
			// 	data.teachers[i] = $(this).val();
			// });

			$ajax({
				url : "/course/upsert",
				data: data,
				success: function(res){
					$alert("创建成功");
					window.location.href = "courseCheck.html";
				}
			});
		});

	},
	conEditInit: function(){
		$ajax({
			url : "/user/list",
			data: {
				category: UTYPE.PROVIDER
			},
			success: function(res){
				var list = res.result.results;
				var html = '';
				for (var i = 0 ; i < list.length ; i ++){
					html += '<option value="' + list[i]._id + '">' + list[i].username + "("+ (list[i].name?list[i].name:"无") +")"+'</option>';
				}
				$("#owner").html(html);
				$ajax({
					url : "/course/detail",
					data : {
						_id: getValue("id")
					},
					success: function(res){
						var course = res.result;
						Course.data = course;
						$("#form").find("input[type='checkbox']:checked").each(function(i){
							data.teachers[i] = $(this).val();
						});
						for (var key in course){
							if (key == "photo")
								$("#photoList").html('<img src="' + Core.IMG_VER + course.photo + '" style="width:100%;"><input id="photo" type="hidden" value="' + course.photo + '">');
							else
								$("#" + key).val(course[key]);
						}
					}
				});
			}
		});
		   
		$("#save").click(function(){
			var data = Course.data;
			$(".form").find('input').each(function(){
				data[$(this).attr("id")] = $(this).val();
			});
			data.owner = $("#owner").val();
			// data.teachers = new Array();
			// $("#form").find("input[type='checkbox']:checked").each(function(i){
			// 	data.teachers[i] = $(this).val();
			// });
			// data.teachers[0] = data.teachers[0]?data.teachers[0]:"";
			$ajax({
				url : "/course/upsert",
				data: data,
				success: function(res){
					$alert("修改成功");
					window.location.href = "courseCheck.html";
				}
			});
		});
		
	},
	treeInit: function(){ 
		$ajax({
			url : "/teacher/list",
			success: function(res){
				var teachers = res.result.results;
				var html = '';
				for (var i = 0 ; i < teachers.length ; i ++){
					html += "<label class='checkbox inline'>" + 
                            "    <input id='" + teachers[i]._id + "' value='" + teachers[i]._id + "' type='checkbox' name='teachers' />" + teachers[i].name + 
                            "</label>";
				}
				$("#teacherList").html(html);
				$ajax({
					url : "/course/detail",
					data : {
						_id: getValue("id")
					},
					success: function(res){
						Course.data = res.result;
						var course = res.result;
						$("#courseName").text(res.result.name);
						for (var i = 0; i < course.teachers.length; i ++){
							$("#"+course.teachers[i]._id).attr("checked",true);
						}
						var html = "";
						for (var i = 0 ; i < course.chapter.length; i ++){
							html += Course.getChapterHtml(course.chapter[i].name,course.chapter[i]) + "<div class='knowledgeEvt'>";
							for (var j = 0; j < course.chapter[i].knowledge.length; j ++ ){
								html += Course.getKnowledgeHtml(course.chapter[i].knowledge[j].name,course.chapter[i].knowledge[j]);
							}
							html += "</div>";
						}
						$(".parentdomEvt").append(html);
						$(".projectTop").click(function(){
							$(this).parents(".parentdomEvt").addClass("selected");
							ShowCover("创建章节","章节名称","","Course.addChapterDom()");
						});
						$("#chapterSave").click(Course.chapterSave);
						$("#knowledgeSave").click(Course.knowledgeSave);
						$("#saveCourse").click(Course.saveCourse);

						$(document).on("click",".chapterEvt .plus",function(){
							var item = $(this).parent().parent().parent(".chapterEvt").data("item");
							if (item){
								var item = (typeof(item)== "object"?item:JSON.parse(item));
								if (item.category == CHAPTERTYPE.COURSEEXAM)
									return $alert("结业考试下不能添加章节");
							}

							$(".chapterEvt").removeClass("selected");
							$(".knowEvent").removeClass("selected");
							$(this).parent().parent().parent(".chapterEvt").addClass("selected");
							ShowCover("创建知识点","知识点名称","","Course.addKnowledgeDom()");
						});
						$(document).on("click",".chapterEvt .edit",function(){
							$(".chapterEvt").removeClass("selected");
							$(".knowEvent").removeClass("selected");
							$(this).parent().parent().parent(".chapterEvt").addClass("selected");
							ShowCover("修改章节","章节名称",$(this).parent().prev().children(".title").text(),"Course.editChapterDom()");
						});
						$(document).on("click",".chapterEvt .remove",function(){
							Course.removeEvt = true;
							$(".detailEvt").css("display","none");
							$(this).parent().parent().parent(".chapterEvt").next(".knowledgeEvt").remove();
							$(this).parent().parent().parent(".chapterEvt").remove();
						});

						$(document).on("click",".knowEvent",function(){
							Course.itemName = $(this).children().children(".knowtitle").text();
							$(".knowEvent").removeClass("selected");
							$(this).addClass("selected");
							Course.showKnowledgeContent();
						});
						$(document).on("click",".knowEvent .knowEdit",function(){
							$(".knowEvent").removeClass("selected");
							$(this).parent().parent(".knowEvent").addClass("selected");
							ShowCover("修改知识点","知识点名称",$(this).parent().prev().children(".knowtitle").text(),"Course.editKnowledgeDom()");
						});
						$(document).on("click",".knowEvent .knowRemove",function(){
							$(this).parent().parent(".knowEvent").remove();
						});
					}
				});
				// $(".projectTop").click(function(){
				// 	$(this).parents(".parentdomEvt").addClass("selected");
				// 	ShowCover("创建章节","章节名称","","Course.addChapterDom()");
				// });
				// $("#chapterSave").click(Course.chapterSave);
				// $("#knowledgeSave").click(Course.knowledgeSave);
				// $("#saveCourse").click(Course.saveCourse);
			}
		});		
	},
	moveUp: function(){
		var $chap = $(".chapterEvt.selected");
		var $know = $(".knowEvent.selected");
		if ($know.length == 0 && $chap.length == 0)
			return $alert("请选择节点再移动");
		if ($know.length > 0) {
			var thisHtml = $know.prop('outerHTML');
			var prevHtml = $know.prev().prop('outerHTML');
			if (prevHtml){ 
				$know.prev().before(thisHtml);
				$know.remove();
			} else 
				$alert("向上移不动啦");
		} else {
			var thisHtml = $chap.prop('outerHTML') + $chap.next(".knowledgeEvt").prop('outerHTML');
			var prevHtml = $chap.prev().prev(".chapterEvt").prop('outerHTML') + $chap.prev(".knowledgeEvt").prop('outerHTML');
			if (prevHtml){ 
				$chap.prev().prev(".chapterEvt").before(thisHtml);
				$chap.next(".knowledgeEvt").remove();
				$chap.remove();
			} else 
				$alert("向上移不动啦");
		}
	},
	moveDown: function(){
		var $chap = $(".chapterEvt.selected");
		var $know = $(".knowEvent.selected");
		if ($know.length == 0 && $chap.length == 0)
			return $alert("请选择节点再移动");
		if ($know.length > 0) {
			var thisHtml = $know.prop('outerHTML');
			var nextHtml = $know.next().prop('outerHTML');
			if (nextHtml){ 
				$know.next().after(thisHtml);
				$know.remove();
			} else 
				$alert("向下移不动啦");
		} else {
			var thisHtml = $chap.prop('outerHTML') + $chap.next(".knowledgeEvt").prop('outerHTML');
			var nextHtml = $chap.next().next(".chapterEvt").prop('outerHTML') + $chap.next().next().next(".knowledgeEvt").prop('outerHTML');
			if (nextHtml){ 
				$chap.next().next().next(".knowledgeEvt").after(thisHtml);
				$chap.next(".knowledgeEvt").remove();
				$chap.remove();
			} else 
				$alert("向上移不动啦");
		}
	},
	getChapterHtml: function(name,data_item){
		var data_item = data_item?'data-item=' + Trim(JSON.stringify(data_item),"g"):"";
		var chapterHtml =	"<div " + data_item + " class='chapterEvt box-content' onclick='Course.toggle();'>" + 
							"	<div class='box-toolbox box-toolbox-top' style='margin:-10px;padding:10px 5px;'>" + 
		                    "   	<div class='pull pull-left'>" + 
		                    "        	<div class='title up5 uf16'>" + name + "</div>" + 
		                    "    	</div>" + 
		                    "    	<div class='pull pull-right'>" + 
		                    "       	<a class='btn btn-white plus' style='padding: 2px 6px;'>" + 
		                    "            	<i class='icon-plus'></i>" + 
		                    "        	</a>" + 
		                    "        	<a class='btn btn-white edit' style='padding: 2px 6px;'>" + 
		                    "            	<i class='icon-edit'></i>" + 
		                    "        	</a>" + 
		                    "        	<a class='btn btn-white remove' style='padding: 2px 6px;'>" + 
		                    "            	<i class='icon-remove'></i>" + 
		                    "        	</a>" + 
		                    "    	</div>" + 
		                    "	</div>" + 
		                    "</div>";
        return chapterHtml;            
	},
	getKnowledgeHtml: function(name,data_knowitem){
		var data_knowitem = data_knowitem?'data-knowitem=' + Trim(JSON.stringify(data_knowitem),"g"):"";
        var knowledgeHtml = "<div " + data_knowitem + " class='box-toolbox box-toolbox-top knowEvent' style='margin:0;padding: 2% 1% 2% 10%;;background-color:#fff;border: 1px solid #dddddd;border-top:none;'>" + 
	                        "   <div class='pull pull-left'>" + 
	                        "        <div class='title up5 uf16 knowtitle'>" + name + "</div>" + 
	                        "    </div>" + 
	                        "    <div class='pull pull-right'>" + 
	                        "        <a class='btn btn-white knowEdit' style='padding: 2px 6px;'>" + 
	                        "            <i class='icon-edit'></i>" + 
	                        "        </a>" + 
	                        "        <a class='btn btn-white knowRemove' style='padding: 2px 6px;'>" + 
	                        "            <i class='icon-remove'></i>" + 
	                        "        </a>" + 
	                        "    </div>" + 
	                        "</div>";
        return knowledgeHtml;            
	},
	addChapterDom: function(){ 
		var name = $("#full-name").val();
		Course.itemName = name;
		$("#cover").html("");
		var chapterdom = Course.getChapterHtml(name) + "<div class='knowledgeEvt'></div>";
		$(".parentdomEvt").append(chapterdom);

		$(".chapterEvt .plus").click(function(){
			var item = $(this).parent().parent().parent(".chapterEvt").data("item");
			if (item){
				var item = (typeof(item)== "object"?item:JSON.parse(item));
				if (item.category == CHAPTERTYPE.COURSEEXAM)
					return $alert("结业考试下不能添加章节");
			}
			$(".chapterEvt").removeClass("selected");
			$(this).parent().parent().parent(".chapterEvt").addClass("selected");
			ShowCover("创建知识点","知识点名称","","Course.addKnowledgeDom()");
		});
		$(".chapterEvt .edit").click(function(){
			$(".chapterEvt").removeClass("selected");
			$(this).parent().parent().parent(".chapterEvt").addClass("selected");
			ShowCover("修改章节","章节名称",$(this).parent().prev().children(".title").text(),"Course.editChapterDom()");
		});
		$(".chapterEvt .remove").click(function(){
			Course.removeEvt = true;
			$(".detailEvt").css("display","none");
			$(this).parent().parent().parent(".chapterEvt").next(".knowledgeEvt").remove();
			$(this).parent().parent().parent(".chapterEvt").remove();
		});
	},
	toggle: function(){
		if (Course.removeEvt)
			return Course.removeEvt = false;
		var $this = $(event.currentTarget);
		Course.itemName = $this.children().children().children(".title").text();
		$(".chapterEvt").removeClass("selected");
		$(".knowEvent").removeClass("selected");
		$this.addClass("selected");
		$(".detailEvt").css("display","none");
		$(".chapterContent").css("display","block");

		$("#category").val(CHAPTERTYPE.CHAPTER);
		$("#desc,#extra").val("");
		$(".chapevt").addClass("hide")
    	$(".chapevt:eq(0)").removeClass("hide")

		if ($this.data("item")){
			var item = (typeof($this.data("item"))== "object"?$this.data("item"):JSON.parse($this.data("item")));
			for (var key in item)
				$("#" + key).val(item[key]);
			$(".chapevt").addClass("hide")
        	$(".chapevt:eq(" + item.category + ")").removeClass("hide")
		}
		var $konw = $this.next(".knowledgeEvt");
		if ($konw.css("display") == "none")
			$konw.slideDown();
		else
			$konw.slideUp();
		Course.chapterSave();
	},
	addKnowledgeDom: function(){ 
		var name = $("#full-name").val();
		Course.itemName = name;
		$("#cover").html("");
		var knowledgedom = Course.getKnowledgeHtml(name);
		$(".chapterEvt.selected").next().append(knowledgedom).css("display","block");
		$(".knowEvent").click(function(){
			Course.itemName = $(this).children().children(".knowtitle").text();
			$(".knowEvent").removeClass("selected");
			$(this).addClass("selected");
			Course.showKnowledgeContent();
			Course.knowledgeSave();
		});
		$(".knowEvent .knowEdit").click(function(){
			$(".knowEvent").removeClass("selected");
			$(this).parent().parent(".knowEvent").addClass("selected");
			ShowCover("修改知识点","知识点名称",$(this).parent().prev().children(".knowtitle").text(),"Course.editKnowledgeDom()");
		});
		$(".knowEvent .knowRemove").click(function(){
			$(this).parent().parent(".knowEvent").remove();
		});
	},
	editChapterDom: function(){
		var name = $("#full-name").val();
		Course.itemName = name;
		$("#cover").html("");
		$(".chapterEvt.selected .title").text(name);
		$(".chapterEvt.selected").next().css("display","block");
		Course.chapterSave();
	},
	editKnowledgeDom: function(){
		var name = $("#full-name").val();
		Course.itemName = name;
		$("#cover").html("");
		$(".knowEvent.selected .knowtitle").text(name);
		Course.knowledgeSave();
	},
	showKnowledgeContent: function(){
		$(".detailEvt").css("display","none");
		$(".knowledgeContent").css("display","block");

		$(".lievt,.tab-pane").removeClass("active");
        $("#tab0,.lievt:eq(0)").addClass("active");
        $("#knowledgeDesc,#knowledgeTarget").val("");

		$(".materialContent,.videoContent").html("");
		if ($(".knowEvent.selected").data("knowitem")){
			var item = (typeof($(".knowEvent.selected").data("knowitem"))== "object"?$(".knowEvent.selected").data("knowitem"):JSON.parse($(".knowEvent.selected").data("knowitem")));
			$("#knowledgeDesc").val(item.desc);
			$("#knowledgeTarget").val(item.target);
			var materialHtml = "";
			for (var i = 0; i < item.material.length; i ++){
				if (!item.material[i].url)
					return;
				materialHtml += "<div class='control-group'>" + 
		                        "    <label class='control-label'>教材名称</label>" + 
		                        "    <div class='controls'>" + 
		                        "        <input class='span12' data-url='" + item.material[i].url + "' name='materialName' placeholder='' type='text' value='" + item.material[i].name + "' />" + 
		                        "        <small class='muted'>教材附件地址 : " + item.material[i].url + "</small>" + 
		                        "       <img class='materClose' src='images/icon_remove.png' style='width:25px;float:right;cursor:pointer;'>" + 
		                        "    </div>" + 
		                        "</div>  ";
			}
			$(".materialContent").append(materialHtml);

			var videoHtml = "";
			for (var i = 0; i < item.video.length; i ++){
				if (!item.video[i].url)
					return;
				videoHtml += "<div class='control-group'>" + 
		                        "    <label class='control-label'>视频名称</label>" + 
		                        "    <div class='controls'>" + 
		                        "        <input class='span12' data-url='" + item.video[i].url + "' name='videoName' placeholder='' type='text' value='" + item.video[i].name + "' />" + 
		                        "        <small class='muted'>视频地址 : " + item.video[i].url + "</small>" + 
		                        "       <img class='videoClose' src='images/icon_remove.png' style='width:25px;float:right;cursor:pointer;'>" + 
		                        "    </div>" + 
		                        "</div>  ";
			}
			$(".videoContent").append(videoHtml);	
			$(".materClose,.videoClose").click(function(){
				$(this).parent().parent().remove();
				Course.knowledgeSave();
			});	
			$ajax({
				url: "/examine/detailKnowledge",
				data:{
					_id: item._id
				},
				success: function(res){
					Course.examInit(res.result,$("#issue"));
				}
			});
		}
	},
	chapterSave: function(){
		var item = $(".chapterEvt.selected").data("item");
		if (item){
			var item = (typeof(item)== "object"?item:JSON.parse(item));
		} else 
			item = new Object();
		item.name = Course.itemName;
		item.category = $("#category").val();
		if (item.category == CHAPTERTYPE.CHAPTER)
			item.desc = $("#desc").val();
		else if (item.category == CHAPTERTYPE.COURSEEXAM)
			item.extra = $("#extra").val();
		$(".chapterEvt.selected").data("item",JSON.stringify(item));
		//$alert("保存成功");
	},
	knowledgeSave: function(){
		var knowitem = $(".knowEvent.selected").data("knowitem");
		if (knowitem){
			var knowitem = (typeof(knowitem)== "object"?knowitem:JSON.parse(knowitem));
		} else 
			knowitem = new Object();
		knowitem.name = Course.itemName;
		knowitem.desc = $("#knowledgeDesc").val();
		knowitem.target = $("#knowledgeTarget").val();
		knowitem.material = new Array();
		$(".materialContent").find("input[name='materialName']").each(function(i){
			knowitem.material[i] = new Object();
			knowitem.material[i].name = $(this).val();
			knowitem.material[i].url = $(this).data("url");
		});
		knowitem.video = new Array();
		$(".videoContent").find("input[name='videoName']").each(function(i){
			knowitem.video[i] = new Object();
			knowitem.video[i].name = $(this).val();
			knowitem.video[i].url = $(this).data("url");
		});
		$(".knowEvent.selected").data("knowitem",JSON.stringify(knowitem));
		// alert($(".knowEvent.selected").data("knowitem"));
		// $alert("知识点保存成功");
	},
	saveCourse: function(){
		var data = Course.data;
		data.chapter = new Array();
		$(".parentdomEvt").find(".chapterEvt").each(function(i){
			var $this = $(this);
			if ($(this).data("item")){
				data.chapter[i] = (typeof($(this).data("item"))== "object"?$(this).data("item"):JSON.parse($(this).data("item")));
			}else
				data.chapter[i] = new Object();
			data.chapter[i].knowledge = new Array();
			$this.next(".knowledgeEvt").find(".knowEvent").each(function(j){
				if ($(this).data("knowitem"))
					data.chapter[i].knowledge[j] = (typeof($(this).data("knowitem"))== "object"?$(this).data("knowitem"):JSON.parse($(this).data("knowitem")));
				else
					data.chapter[i].knowledge[j] = new Object();
			});
			if (data.chapter[i].category == CHAPTERTYPE.COURSEEXAM)
				data.chapter[i].knowledge = [];
		});
		data.teachers = new Array();
		$("#teacherList").find("input[type='checkbox']:checked").each(function(i){
			data.teachers[i] = $(this).val();
		});
		if(data.teachers.length < 1)
			return $alert("还未选择讲师");
		$ajax({
			url : "/course/upsert",
			data: data,
			success: function(res){
				$alert("课程编辑完成");
			}
		});
	},
 	listClick: function(pageclickednumber){
	      var cont = GetLS("cont");
	      Course.listJump(pageclickednumber);
	      $("#listPager").pager({pagenumber: pageclickednumber, pagecount: cont, buttonClickCallback: Course.listClick });
 	},
 	listJump: function(pageno){
 		var count = Res.sinCount;
      	var start = (pageno-1)*count;
      	var owner = CurrentUser.category == UTYPE.PROVIDER?CurrentUser._id:"";
		$ajax({
			url: "/course/list",
			data: {
            	start : start,
                count : count,
                owner: owner
           	},
			success: function(res) {
				var cont = parseInt(res.result.count/Res.sinCount);
                if((res.result.count)%Res.sinCount!=0){
                     cont++;
                }
                SetLS("cont",cont);
                if($("#listPager").children().length == 0)
                     $("#listPager").pager({ pagenumber: pageno, pagecount: cont, buttonClickCallback: Course.listClick });
				var html = '<thead><tr>'+
                            '<th class="span3">名称</th>'+  
                            '<th class="span4">描述</th>'+
                            '<th class="span2">拒绝理由</th>'+
                            '<th class="span2">状态</th>'+
                            '<th class="span4">操作</th>'+
	                    '</tr></thead><tbody>';

	            var items = res.result.results;
	            var desc = "";
	            for (var i=0; i<items.length; i++) {
	            	desc = items[i].desc?items[i].desc:"无";
	            	html += '<tr data-pos="'+ i +'">'+
	            				'<td>'+ items[i].name +'</td>'+   
	            				'<td class="umw15">'+ desc +'</td>'+
	            				'<td class="umw15">'+ (items[i].rejectDes?items[i].rejectDes:"") +'</td>'+
	            				'<td id="' + items[i]._id + '" class="umw15">'+ STATUS_HTML[items[i].status] +'</td>'+
	            				'<td>';
	            				
            		if(items[i].status != STATUS.PASS){
    					html+=	'<button class="btn btn-success updateBtn">编辑</button> ' + 
            					'<button class="btn btn-danger addExam">添加试题</button>' +
            					'<button data-id="' + items[i]._id + '" data-name="' + items[i].name + '" class="btn btn-primary submit" style="margin: 0 5px;">提交<i class="icon-ok"></i></a>';
            		}
    				else{
    					html+=	'<button disabled = "disabled" class="btn  updateBtn">编辑</button> ' + 
            					'<button disabled = "disabled" class="btn  addExam">添加试题</button>' +
            					'<button disabled = "disabled" data-id="' + items[i]._id + '" data-name="' + items[i].name + '" class="btn  submit" style="margin: 0 5px;">提交<i class="icon-ok"></i></a>';
    				}
        			html+=	'</td>'+
        			'</tr>';

	            }
	            html += '</tbody>';
	            $("#tabCtn").html(html);
	           	$(".updateBtn").click(function() {
	            	var item = items[$(this).parents("tr").data("pos")];
	            	window.location.href = "/courseEdit.html?id="+item._id;
	            });
	            $(".addExam").click(function(){
	            	var item = items[$(this).parents("tr").data("pos")];
	            	window.location.href = "/courseExam.html?id="+item._id;
	            });
	            $(".submit").click(function(){
	            	var id = $(this).data("id");
	            	$ajax({
	            		url: "/course/chengeStatus",
	            		data: {
	            			_id:id,
	            			name:$(this).data("name"),
	            			status: STATUS.COMMIT
	            		},
	            		success: function(res){
	            			$alert("提交成功");
	            			$("#" + id).html(STATUS_HTML[STATUS.COMMIT]);
	            		}	
	            	});
	            });
			}
		});	          
 	},
	listInit: function(){ 
		 this.listJump(1);
	},	
	recommendlistClick: function(pageclickednumber){
	      var cont = GetLS("cont");
	      Course.recommendJump(pageclickednumber);
	      $("#listPager").pager({pagenumber: pageclickednumber, pagecount: cont, buttonClickCallback: Course.recommendlistClick });
 	},//lcy
 	recommendJump: function(pageno){
 		var count = Res.sinCount;
      	var start = (pageno-1)*count;
		$ajax({
			url: "/course/list",
			data: {
            	start : start,
                count : count,
                status: STATUS.PASS
           	},
			success: function(res) {
				var cont = parseInt(res.result.count/Res.sinCount);
                if((res.result.count)%Res.sinCount!=0){
                     cont++;
                }
                SetLS("cont",cont);
                if($("#listPager").children().length == 0)
                     $("#listPager").pager({ pagenumber: pageno, pagecount: cont, buttonClickCallback: Course.recommendlistClick });
				var html = '<thead><tr>'+
                            '<th class="span3">名称</th>'+  
                            '<th class="span5">描述</th>'+
                            '<th class="span2">状态</th>'+
                            '<th class="span2">操作</th>'+
	                    '</tr></thead><tbody>';

	            var items = res.result.results;
	            var desc = "";
	            for (var i=0; i<items.length; i++) {
	            	var status = items[i].recommend?STATUS.RECOMMEND:STATUS.UNRECOMMEND;
	            	var operation = items[i].recommend?"取消推荐":"设为推荐";                    
	            	var recommend = items[i].recommend?"false":"true";
	            	desc = items[i].desc?items[i].desc:"无";
	            	html += '<tr data-pos="'+ i +'">'+
	            				'<td>'+ items[i].name +'</td>'+   
	            				'<td class="umw15">'+ desc +'</td>'+
	            				'<td id="' + items[i]._id + '"class="umw15">'+ STATUS_HTML[status] +'</td>'+
	            				'<td>'+ 
            					'<button data-id="' + items[i]._id + '" data-recommend="' + recommend + '" class="btn btn-primary recommendBtn" style="margin: 0 5px;">'+ operation +'</a>'+ 
	            				'</td>'+
	            			'</tr>';

	            }
	            html += '</tbody>';
	            $("#tabCtn").html(html);
	            $(".recommendBtn").click(function(){
	            	var $this = $(this);
	            	var id = $(this).data("id");
	            	var recommend = $(this).data("recommend");
	            	$ajax({
	            		url: "/course/recommend",
	            		data: {
	            			_id:id,
	            			recommend:recommend
	            		},
	            		success: function(res){
	            			// $alert("变换成功");
							var status =  (recommend == true)?STATUS_HTML[STATUS.RECOMMEND]:STATUS_HTML[STATUS.UNRECOMMEND];
							var operation = (recommend == true)?"取消推荐":"设为推荐";
							var rec = !recommend;
							$("#" + id).html(status);
							$this.html(operation).data("recommend", rec);	            			
	            		}	
	            	});
	            });
			}
		});	          
 	},
	recommendInit: function(){ 
		 this.recommendJump(1);
	},				
	checkClick: function(pageclickednumber){
	      var cont = GetLS("cont");
	      Course.checkJump(pageclickednumber);
	      $("#checkPager").pager({pagenumber: pageclickednumber, pagecount: cont, buttonClickCallback: Course.checkClick });
 	},
 	checkJump: function(pageno){
 		var count = Res.sinCount;
      	var start = (pageno-1)*count;
      	var owner = CurrentUser.category == UTYPE.PROVIDER?CurrentUser._id:"";
 		$ajax({
			url: "/course/list",
			data: {
            	start : start,
                count : count,
                owner: owner
           	},
			success: function(res) {
				var cont = parseInt(res.result.count/Res.sinCount);
                if((res.result.count)%Res.sinCount!=0){
                     cont++;
                }
                SetLS("cont",cont);
                if($("#checkPager").children().length == 0)
                     $("#checkPager").pager({ pagenumber: pageno, pagecount: cont, buttonClickCallback: Course.checkClick });
				var html = '<thead><tr>'+
                            '<th class="span3">课程名称</th>'+  
                            '<th class="span2">创建时间</th>'+                              
                            '<th class="span2">状态</th>'+
                            '<th class="span2">拒绝理由</th>'+
                            '<th class="span4">操作</th>'+
	                    '</tr></thead><tbody>';
	            var items = res.result.results;
	            Course.items = items;
	            for (var i=0; i<items.length; i++) {
                     html +=   "<tr>" + 
                               "   <td>" + items[i].name + "</td>" + 
                               "   <td>" + (new Date(items[i].create)).pattern("yyyy-MM-dd") + "</td>" + 
                               "   <td id='" + items[i]._id + "' class='prostatus'>" + STATUS_HTML[items[i].status] + "</td>" + 
                               "   <td class='rejectDes'>" + (items[i].rejectDes?items[i].rejectDes:"") + "</td>" + 
                               "   <td>";
                               if(items[i].status == 1 || items[i].status == 3){
                               	html +="<a data-num='" + i + "' data-action='PASS' class='btn btn-success btn-mini'>通过<i class='icon-ok'></i></a>" + 
                               "  <a data-num='" + i + "' data-action='REJECT' class='btn btn-danger btn-mini'>拒绝<i class='icon-remove'></i></a>" + 
                               "  <a data-num='" + i + "' class='btn btn-info btn-mini'>修改<i class='icon-fullscreen'></i></a>" + 
                               "  <a data-num='" + i + "' class='btn btn-inverse btn-mini'>编辑树<i class='icon-align-left'></i></a>" + 
                               "  <a data-num='" + i + "' class='btn btn-remove btn-mini'>删除<i class='icon-remove'></i></a>" + 
                               "  </td>";
                               }else{
                               html+=	" <a data-num='" + i + "' data-action='PASS' class='btn btn-mini'>通过<i class='icon-ok'></i></a>" + 
                               " <a data-num='" + i + "' data-action='REJECT' class='btn btn-mini'>拒绝<i class='icon-remove'></i></a>" + 
                               " <a data-num='" + i + "' class='btn btn-info btn-mini'>修改<i class='icon-fullscreen'></i></a>" + 
                               " <a data-num='" + i + "' class='btn btn-inverse btn-mini'>编辑树<i class='icon-align-left'></i></a>" + 
                               " <a data-num='" + i + "' class='btn btn-remove btn-mini'>删除<i class='icon-remove'></i></a>" + 
                               "   </td>" ; 
                               }
                               
                               html+="</tr>";	            			
	            }
	            html += '</tbody>';
	            $("#tabCtn").html(html);
	            
                $(".btn-success").click(function(){
                    var $this = $(this);
                     var item = Course.items[$(this).data("num")];
                     item.status = STATUS[$(this).data("action")];
                     item.rejectDes = "";
                     $ajax({
                          url: "/course/chengeStatus",
                          data: item,
                          success: function(res){
                               $alert("状态变更成功");
                               $("#"+item._id).html(STATUS_HTML[item.status]);
                               $("#"+item._id).next(".rejectDes").text("");
                               $this.unbind("click");
                               $this.next().unbind("click");
                               $this.removeClass("btn-success");
                               $this.next().removeClass("btn-danger");
                          }
                     });
                });	        

                $(".btn-danger").click(function(){
                     var $this = $(this);
                     var item = Course.items[$(this).data("num")];
                     item.status = STATUS[$(this).data("action")];

                     if (item.status == STATUS.REJECT){
                          SetLS("courseItem",item);
                          ShowCover("提示信息","请输入拒绝理由","","Course.reject()");
                     }
                });
                 $(".btn-info").click(function() {
	            	var item = Course.items[$(this).data("num")];
	            	window.location.href = "/courseConEdit.html?action=edit&id="+item._id;
	            });
	            $(".btn-inverse").click(function() {
	            	var item = Course.items[$(this).data("num")];
	            	window.location.href = "/courseEdit.html?action=view&id="+item._id;
	            });

	            $(".btn-remove").click(function() {
	            	var item = Course.items[$(this).data("num")];
		        	if(window.confirm('你确定要删除课程“' +  item.name + '”吗？删除后将不能恢复！')){
		            	$ajax({
		            		url:"/course/remove",
		            		data:{_id:item._id},
		            		success: function() {
		            			window.location.href = "/courseCheck.html";
		            		}
		            	});
		          	}	            	
	            });	            

	           	$(".updateBtn").click(function() {
	            	var item = items[$(this).parents("tr").data("pos")];
	            	window.location.href = "/courseCreate.html?id="+item._id;
	            });
			}
		});	         
 	},
	checkInit: function(){ 
	   	this.checkJump(1);
	},	
	reject: function(){
	  var item = GetLS("courseItem");
	  item.rejectDes = $("#full-name").val();
	  $ajax({
	       url: "/course/chengeStatus",
	       data: item,
	       success: function(res){
	            $("#"+item._id).html(STATUS_HTML[item.status]);
	            $("#"+item._id).next(".rejectDes").text($("#full-name").val());
	            $("#cover").html("");
	            $("#"+item._id).next().next().find("a").removeClass("btn-danger");
                $("#"+item._id).next().next().find("a").removeClass("btn-success");
                $("#"+item._id).next().next().find("a").each(function(){
                  if($(this).attr("data-action")){
                    $(this).unbind("click");
                  }
                });
	       }
	  });
	},
	examTreeInit: function(){
		$ajax({
			url : "/course/detail",
			data : {
				_id: getValue("id")
			},
			success: function(res){
				Course.data = res.result;
				var course = res.result;
				$("#courseName").text(res.result.name);
				var html = "";
				for (var i = 0 ; i < course.chapter.length; i ++){
					html += Course.examGetChapterHtml(course.chapter[i].name,course.chapter[i]) + "<div class='knowledgeEvt'>";
					for (var j = 0; j < course.chapter[i].knowledge.length; j ++ ){
						html += Course.examGetKnowledgeHtml(course.chapter[i].knowledge[j].name,course.chapter[i].knowledge[j]);
					}
					html += "</div>";
				}
				$(".parentdomEvt").append(html);

				$("#examSave").click(Course.examSave);
				$("#saveCourse").click(Course.saveCourseExam);

				$(".knowEvent").click(function(){
					Course.itemName = $(this).children().children(".knowtitle").text();
					$(".examContent").removeClass("hide");
					$(".lievt.active font").text(Course.itemName);
					$(".knowEvent").removeClass("selected");
					$(this).addClass("selected");
					Course.showExamContent();
				});
			}
		});
	},
	examToggle: function(){
		var $this = $(event.currentTarget);
		var item = $this.data("item");

		var $konw = $this.next(".knowledgeEvt");
		if ($konw.css("display") == "none")
			$konw.slideDown();
		else
			$konw.slideUp();
		if (item.category == CHAPTERTYPE.CHAPTER)
			return;
		Course.itemName = $this.children().children().children(".title").text();
		$(".chapterEvt").removeClass("selected");
		$this.addClass("selected");
		$(".examContent").removeClass("hide");
		$(".lievt.active font").text(item.name);
		Course.showExamContent(item._id);
	},
	examGetChapterHtml: function(name,data_item){
		var data_item = data_item?'data-item=' + Trim(JSON.stringify(data_item),"g"):"";
		var chapterHtml =	"<div " + data_item + " class='chapterEvt box-content' onclick='Course.examToggle();'>" + 
							"	<div class='box-toolbox box-toolbox-top examEvt' style='margin:-10px;padding:10px 5px;'>" + 
		                    "   	<div class='pull pull-left'>" + 
		                    "        	<div class='title up5 uf16'>" + name + "</div>" + 
		                    "    	</div>" + 
		                    "	</div>" + 
		                    "</div>";
        return chapterHtml;            
	},
	examGetKnowledgeHtml: function(name,data_knowitem){
		var data_knowitem = data_knowitem?'data-knowitem=' + Trim(JSON.stringify(data_knowitem),"g"):"";
        var knowledgeHtml = "<div " + data_knowitem + " class='box-toolbox box-toolbox-top knowEvent' style='margin:0;padding: 2% 1% 2% 10%;;background-color:#fff;border: 1px solid #dddddd;border-top:none;'>" + 
	                        "   <div class='pull pull-left'>" + 
	                        "        <div class='title up5 uf16 knowtitle'>" + name + "</div>" + 
	                        "    </div>" + 
	                        "</div>";
        return knowledgeHtml;            
	},
	examSave: function(){
		var item = $(".knowEvent.selected").data("knowitem");
		//alert(item._id);
	},
	showExamContent: function(_id){
		$(".detailEvt").css("display","none");
		$(".examContent").css("display","block");
		var id = _id?_id:$(".knowEvent.selected").data("knowitem")._id;
		$ajax({
			url: "/examine/detailKnowledge",
			data:{
				_id: id
			},
			success: function(res){
				Course.examInit(res.result,$("#issue"));
			}
		});
	},
	examInit: function(res, $dom){
		var html = "";
		for (var i = 0; i < res.length; i ++){
			if (res[i].QuestionType == EXAMTYPE.SINGLE_CHOICE){//单选
				html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                            '<div class="mkyl-title">' + (i + 1) + "." +  EXAMTYPE_LABEL[res[i].QuestionType] + '<span class="score" data-score="' + res[i].QScore + '">' + 
                            //res[i].QScore + 注释掉分数
                            '</span></div>' + 
                            '<div class="mkyl-zw">' + 
                                '<div class="mkyl-box" style="border-bottom:none;">' + res[i].Content + '</div>';
                    for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
                    	html += '<span>' + 
                                    '<label><input type="radio" data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</label>' + 
                                '</span>';
                    }
                    var trueChoice = "";
                    //html += '<div class=" tipEvt" style="padding-top:20px;"><font style="font-weight:bold">正确答案：</font>';
	                		for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	if (res[i].QuestionOptionList[j].IfRightAnswer == "true"||res[i].QuestionOptionList[j].IfRightAnswer == true){
	                        		trueChoice +=  res[i].QuestionOptionList[j].Content + '；';
	                        		 
	                        	}          		
	                        }
	                        	html += 	'<div id="right" class="daan daan-2 tipEvt" style="border-bottom:none;">正确答案：'+ trueChoice + '</div>';
                    html += '<div class="jiexi tipEvt">'+
												'<div class="left jiexi-left" style="font-weight: bold;">解析：</div>'+
												'<div class="right jiexi-right">' + ((res[i].Tip)==undefined ?'等等，会有的！':res[i].Tip) + '</div>' + 
                    		'</div>' +
                    		'</div>' +
                        '</div>';
			}
			else if (res[i].QuestionType == EXAMTYPE.MULTIPLE_CHOICE){//多选
				html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                            '<div class="mkyl-title">' + (i + 1) + "." +  EXAMTYPE_LABEL[res[i].QuestionType] + '<span class="score" data-score="' + res[i].QScore + '">' + 
                            //res[i].QScore + 注释掉分数
                            '</span></div>' + 
                            '<div class="mkyl-zw">' + 
                                '<div class="mkyl-box" style="border-bottom:none">' + res[i].Content + '</div>';
                    for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
                    	html += '<span>' + 
                                    '<label><input type="checkbox" data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</label>' + 
                                '</span>';
                    }      
                    //html += '<div class= tipEvt" style="padding-top:20px;"><font style="font-weight:bold">正确答案：</font>';
                    		var multiple_res ="";
                    		for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	if (res[i].QuestionOptionList[j].IfRightAnswer == "true"||res[i].QuestionOptionList[j].IfRightAnswer == true){
	                        		multiple_res += res[i].QuestionOptionList[j].Content +"；";
	                        	}          		
	                        }
	                        		html += '<div class="daan daan-2 tipEvt" style="border-bottom:none;">正确答案：'+ multiple_res + '</div>';
            					
	                html += '</div>'
                    html += '<div class="jiexi tipEvt">'+
									'<div class="left jiexi-left " style="font-weight: bold; font-size:16px;">解析：</div>'+
									'<div class="right jiexi-right" style="line-height:200%;font-size:16px">' + ((res[i].Tip)==undefined ?'等等，会有的！':res[i].Tip) + '</div>' + 
                    		'</div>' +
                    		'</div>'  
                        '</div>';     
			}
			else if (res[i].QuestionType == EXAMTYPE.JUDGE){//判断
				html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                            '<div class="mkyl-title">' + (i + 1) + "." +  EXAMTYPE_LABEL[res[i].QuestionType] + '<span class="score" data-score="' + res[i].QScore + '">' + 
                            //res[i].QScore + 注释掉分数 
                            '</span></div>' + 
                            '<div class="mkyl-zw">' + 
                                '<div class="mkyl-box" style="border-bottom:none">' + res[i].Content + '</div>';
                    for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
                    	html += '<span>' + 
                                    '<label><input type="radio" data-ifrightanswer="' + res[i].QuestionOptionList[j].IfRightAnswer + '" name="' + res[i].QuestionOptionList[j].Exam_BankQuestionId + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</label>' + 
                                '</span>';
                    }     
                    //html += '<div class="hide tipEvt" style="padding-top:20px;"><font style="font-weight:bold">正确答案：</font>';
                    		for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                        	if (res[i].QuestionOptionList[j].IfRightAnswer == "true"||res[i].QuestionOptionList[j].IfRightAnswer == true){
	                        		//html += res[i].QuestionOptionList[j].Content ;
	                        		html += 	'<div class="daan daan-2 tipEvt" style="border-bottom:none;">正确答案：'+res[i].QuestionOptionList[j].Content + '</div>';
	                        	}          		
	                        } 
                    html += '</div><div class="jiexi tipEvt">'+
								'<div class="left jiexi-left" style="font-weight: bold;">解析：</div>'+
								'<div class="right jiexi-right" style="line-height:200%;font-size:16px">' + ((res[i].Tip)==undefined ?'等等，会有的！':res[i].Tip) + '</div>' + 
                    		'</div>' +
                    		'</div>'  
                        '</div>'; 
			}
			else if (res[i].QuestionType == EXAMTYPE.LIGATURE){//连线
				html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                            '<div class="mkyl-title">' + (i + 1) + "." +  EXAMTYPE_LABEL[res[i].QuestionType] + '<span class="score" data-score="' + res[i].QScore + '">' + 
                            //res[i].QScore + 注释掉分数
                            '</span></div>' + 
                            '<div class="mkyl-zw">' + 
                                '<div class="mkyl-box" style="border-bottom:none">' + res[i].Content + '</div>' + 
                    			'<div class="matchByLineBox mlBoxCol" style="width:80%;border-bottom:none;height:14em">';
                    			var left = '<div class="matchSide matchSideQue" style="border:none">';
                    			var right = '<div class="matchSide matchSideAns" style="border:none">';
                    			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
	                            		left += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</div>';
	                            	}
	                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
	                            		right += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '">' + res[i].QuestionOptionList[j].Content + '</div>';
	                            	}
	                            }
	                            left += '</div>';
	                            right += '</div>';
                   			html += left + right + 
                   			'</ul>' + 
                        '</div>';     
                    html += '<div class="tipEvt" style="padding-left:1.3em;">点击下面内容查看正确答案 : </div>' + 
                    		'<ul class="tipEvt" style="margin:0;">' + 
                    			'<div class="matchByLineBox mlBoxCol" style="width:90%;border-bottom:none;height:14em">';
                    			var left = '<div class="matchSide matchSideQue" style="border:none">';
                    			var right = '<div class="matchSide matchSideAns" style="border:none">';
                    			for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
	                            	if (res[i].QuestionOptionList[j].OrderNum%2 == 1){
	                            		for (var l = 0; l < res[i].QuestionOptionList.length; l ++){
	                            			if (res[i].QuestionOptionList[l].OrderNum == res[i].QuestionOptionList[j].OrderNum+1)
	                            				var ans = res[i].QuestionOptionList[l].Id;
	                            		}
	                            		left += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0" ans="' + ans + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
	                            	}
	                            	else if (res[i].QuestionOptionList[j].OrderNum%2 == 0){
	                            		right += '<div class="matchOne lianxian" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" id="' + res[i].QuestionOptionList[j].Id + '0">' + res[i].QuestionOptionList[j].Content + '</div>';
	                            	}
	                            }
	                            left += '</div>';
	                            right += '</div>';
                   			html += left + right + 
                   			'</ul>' +   
                   			'<div class="jiexi tipEvt">'+
									'<div class="left jiexi-left " style="font-weight: bold;">解析：</div>'+
									'<div class="right jiexi-right" style="line-height:200%;font-size:16px">' + ((res[i].Tip)==undefined ?'等等，会有的！':res[i].Tip) + '</div>' + 
                    		'</div>' +
                    		'</div>'  
                        '</div>';   
			}
			else if (res[i].QuestionType == EXAMTYPE.SORT){//排序
				//冒泡排序,用于正确答案
				var temp = 0;
				var targetArr = res[i].QuestionOptionList;
	            for(var k = 0;k<targetArr.length;k++){
	                for(var j = k;j<targetArr.length;j++){
	                    if(targetArr[k].OrderNum>targetArr[j].OrderNum){
	                        temp = targetArr[k];
	                        targetArr[k] = targetArr[j];
	                        targetArr[j] = temp;
	                     }
	                 }
	            }
				html += '<div class="cnt" data-num="' + i + '" data-questiontype="' + res[i].QuestionType + '" data-id="' + res[i].Id + '">' + 
                            '<div class="mkyl-title">' + (i + 1) + "." +  EXAMTYPE_LABEL[res[i].QuestionType] + '<span class="score" data-score="' + res[i].QScore + '">' + 
                            //res[i].QScore + 注释掉分数 
                            '</span></div>' + 
                            '<div class="mkyl-box" style="border-bottom:none;font-size:16px;line-height: 30px;">' + res[i].Content + '</div>' + 
                            '<div class="custom_order" id="custom_order">' + 
		                    '    <div class="custom_sort_form">' + 
		                    '        <ul class="sort_div" id="sort_div">';
                    for (var j = 0; j < res[i].QuestionOptionList.length; j ++){
                    	html += '<li id="' + res[i].QuestionOptionList[j].Id + '" data-ordernum="' + res[i].QuestionOptionList[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;">' + 
                                '    <div class="v_middle" id="' + res[i].QuestionOptionList[j].Id + '_h" style="cursor: move;">' + res[i].QuestionOptionList[j].Content + '</div>' + 
                                '</li>';
                    }      
	                    html += '	 </ul>' ;
	                    		//'<div class="hide tipEvt" style="padding-top:20px;"><font style="font-weight:bold;font-size:16px">正确答案：</font></div>';
		                		var sortTrue = "";
		                		for (var j = 0; j < targetArr.length; j ++){
		                        sortTrue  += '<li class="tipEvt" id="' + targetArr[j].Id + '" data-ordernum="' + targetArr[j].OrderNum + '" class="drag_li" style="left: 0px; top: 0px;width:70%;margin:0.5em auto;">' + 
			                                '    <div class="v_middle" id="' + targetArr[j].Id + '_h" style="cursor: move;">' + targetArr[j].Content + '</div>' + 
			                                '</li>';
	                        	}
	                        	html += '<div class="daan daan-2 tipEvt" style="width:80%;height:480px; border-bottom:none;font-size: 16px;">正确答案：'+ sortTrue +'</div>' + 
								'<div class="jiexi tipEvt" style="border:none">' +'<div class="left jiexi-left" style="font-weight: bold;">解析 : </div>'+'<div class="right jiexi-right" style="line-height:200%;font-size:16px">'+ ((res[i].Tip)==undefined?'等等，会有的！':res[i].Tip) +'</div></div>' + 
                        '</div>' + 
		                    '</div>' + 
		                '</div>';            
			}
		}
		
		$dom.html(html);
		// 初始化连线canvas
		var mblBoxs=$(".matchByLineBox");
		mblArr=[];//全局 存储所有mbl实例
		mblBoxs.each(function(x){
			var mbl=new MatchByLine(mblBoxs.eq(x));
			mbl.init();
			mblArr.push(mbl);
		});
		// 初始化拖动排序
		initDrag();
	},
	export: function(){
		window.open("/examine/exportTemplate?_id=" + getValue("id"));
	},
	showTable: function(contentHtml){
          var cover = "<div class='modal hide fade in' id='modal-example2' style='width:80%;left:10%;margin-left:0;' role='dialog' tabindex='-1'>" + 
                         "    <div class='modal-header'>" + 
                         "        <button class='close closeCover' data-dismiss='modal' type='button'>&times;</button>" + 
                         "        <h3>试题列表</h3>" + 
                         "    </div>" + 
                         "    <div class='modal-body'>" + 
                         contentHtml +
                         "    </div>" + 
                         "    <div class='modal-footer'>" + 
                         "        <button id='saveCover' class='btn btn-primary'>保存</button>" + 
                         "        <button class='btn closeCover'>关闭</button>" + 
                         "    </div>" + 
                         "</div>" + 
                         "<div class='modal-backdrop fade in'></div>";
          if ($("#cover").length == 0)
               $("body").append('<div id="cover"></div>');
          $("#cover").html(cover);
          $(".closeCover").click(function(){
               $("#cover").html("");
          });
          $("#saveCover").click(Course.saveImport);
    },
	saveImport: function(){
		var data = GetLS("importExam");
		$ajax({
			url: "/examine/importQue",
			data: {
				values:JSON.stringify(data)
			},
			success: function(res){
				$alert("试题导入成功");
				window.location.reload();
			}
		});
	}
}